package com.uestc.servlet.statistics;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.uestc.admin.UserLogAdmin;
import com.uestc.servlet.ServletBase;
import com.uestc.util.Log;

@WebServlet("/admin/AnalyseCharts")
public class AnalyseCharts extends HttpServlet implements ServletBase {
	private static final long serialVersionUID = 1L;

	public AnalyseCharts() {
		super();
	}

	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String opt = getParameter(request, "opt");
		String time = getParameter(request, "time");
		if (isArgumentNullOrEmpty(opt, time))
			return;
		
		UserLogAdmin admin = new UserLogAdmin();
		int t = Integer.valueOf(time);
		try {
			String msg = admin.getUserLog(t);
			Log.logger.info(msg);
			writeMessage(response, msg);
		} catch (Throwable e) {
			Log.logException(e);
		}
	}
}
